﻿using System;
using System.Windows;
using System.Windows.Controls.Primitives;

namespace WpfControlsTest {

    [StyleTypedPropertyAttribute(Property = "ItemContainerStyle", StyleTargetType = typeof(Projection))] 
    public class ProjectionContainer : Selector {

        public static DependencyProperty TitleProperty;

        static ProjectionContainer() {
            DefaultStyleKeyProperty.OverrideMetadata(typeof(ProjectionContainer), new FrameworkPropertyMetadata(typeof(ProjectionContainer)));

            TitleProperty = DependencyProperty.Register(
                "Title", typeof(string), typeof(ProjectionContainer),
                new FrameworkPropertyMetadata(String.Empty));
            
        }

        public string Title {
            get { return (string)GetValue(TitleProperty); }
            set { SetValue(TitleProperty, value); }
        }

        protected override void OnInitialized(EventArgs e)
        {
            base.OnInitialized(e);

            if (base.HasItems)
            {
                base.SetCurrentValue(Selector.SelectedIndexProperty, 0);
            }
        }
    }
}
